<?php require_once('header.php'); ?>
<?php //include_once('topwidget.php'); ?>

<div id="contentBox">
<?php include_once('sidebar.php'); ?>

<div id="content">
<?php
	$messages = "SELECT message.msgid, message.senderid, message.receiverid, message.`subject`, message.message, users.userid, users.username, users.username, reply.r_replyid, reply.r_senderid, reply.r_receiverid, reply.r_message FROM message, users, reply WHERE message.senderid=users.userid AND message.msgid=reply.msgid AND receiverid = 1 GROUP BY message.msgid ORDER BY msgid DESC LIMIT 6";
	//$messages = "SELECT message.msgid, message.senderid, users.username, message.receiverid, message.`subject`, message.message, users.userid, users.username 
//FROM message, users WHERE message.senderid=users.userid and receiverid = 1 GROUP BY message.msgid ORDER BY msgid DESC LIMIT 6";
	connection();
	$fetch = mysql_query($messages);
	
	while($rows = mysql_fetch_array($fetch)) {
		echo "<strong>Sender Name: </strong>".$rows['username']."<br/>";
		echo $rows['subject']."<br/>";
		echo $rows['message']."<br/><a href='reply.php?msgid=$rows[msgid]'>Reply</a><hr/>";
	}
?>
</div>
<div style="clear:both;"></div>

<?php //include_once('bottomwidget.php'); ?>
<?php include_once('footer.php'); ?>
